//
//  JWLandscape.h
//  KotH
//
//  Created by James Weatherley on 01/08/2008.
//  Copyright 2008 James Weatherley. All rights reserved.
//

#import <Foundation/Foundation.h>

@class JWSquare;


typedef enum JWLandscapeMode {
	JWLandscapeLaminar,
	JWLandscapeCubic,
	JWLandscapeSmooth
} JWLandscapeMode;


@interface JWLandscape : NSObject <NSCoding>
{
	NSUInteger maxX;
	NSUInteger maxZ;
	NSUInteger sentinelCount;
	NSUInteger level;
	
	NSMutableArray* landscape;
	NSMutableArray* lowSquares;
	NSMutableArray* highSquares;
	
	JWSquare* selectedSquare;
	JWSquare* highSquare;
	
	JWLandscapeMode landscapeMode;
}

#pragma mark Initialisers
-(id)initWithLevel:(NSUInteger)level populate:(BOOL)populate;

@property (readonly) NSUInteger maxX;
@property (readonly) NSUInteger maxZ;
@property (readonly) NSUInteger level;
@property (readonly) NSArray* lowSquares;
@property (readonly) NSArray* highSquares;
@property (readwrite, assign) JWSquare* selectedSquare;
@property (readonly) JWSquare* highSquare;
@property (readonly) JWLandscapeMode landscapeMode;

#pragma mark -
#pragma mark Overrides
-(NSString*)description;

#pragma mark -
#pragma mark Implementation
-(void)generateWithTrees:(BOOL)wantTrees;
-(int)size;
-(CGSize)dimensions;
-(void)plantTree;

#pragma mark Geting squares
-(JWSquare*)getSquareAtX:(NSUInteger)x z:(NSUInteger)z;

// Returns all squares containing a tree within kothMeanieRange of the Player.
-(NSArray*)getTreeSquaresNearPlayer;

// Returns all empty, flat squares lower than height.
// If there aren't any it will increment height until it can return a non-empty set.
-(NSArray*)getSquaresLowerThanHeight:(NSUInteger)height;

@end